<?php
include_once './model/member.php';
class MemberController {
	public function invoke () {
		$member = new Member();
		if (isset($_GET['edit_member'])) {
			$member -> updateMember ('pronsweb',2,'adib sajalah','adib sajalah','ghj','','','','','','');

			$sucsess = $member-> updateMember(($_POST['id_user']),($_POST['id_userkat']),($_POST['password']),($_POST['namadepan'])
			,($_POST['namabelakang']) ,($_POST['alamatuser']) ,($_POST['notelpuser']),($_POST['kotauser'])
			,($_POST['emailuser']),($_POST['kodeposuser']),($_POST['fotouser']));
			if ($sucsess) {
				header('location:./view/home_user.php?id_user='.$_GET['edit_member'].'');
			} else {
				header('location:./view/form_edit_member.php?edit='.$_GET['edit_member'].'');
			}	
					
		} elseif (isset($_POST['id_user']) and isset($_POST['id_userkat']) and isset($_POST['password']) and isset($_POST['namadepan'])
			and isset($_POST['namabelakang']) and isset($_POST['alamatuser']) and isset($_POST['notelpuser']) and isset($_POST['kotauser'])
			and isset($_POST['emailuser']) and isset($_POST['kodeposuser']) and isset($_POST['fotouser'])) {
			
			$sucsess = $member -> addnewmember (($_POST['id_user']),($_POST['id_userkat']),($_POST['password']),($_POST['namadepan'])
			,($_POST['namabelakang']) ,($_POST['alamatuser']) ,($_POST['notelpuser']),($_POST['kotauser'])
			,($_POST['emailuser']),($_POST['kodeposuser']),($_POST['fotouser']));
			
			if ($sucsess) {
				header('location:./view/login.php');
			} else {
				header('location:./view/form_member.php');
			}
			
		} elseif (isset($_GET['member'])) {
			header('location:./view/home_user.php?id_user='.$_GET['member'].'');
		} 
	}
}